$(function() {
    var key = getCookie('key');
    if (!key) {
        window.location.href = WapSiteUrl+'/tmpl/member/login.html';
        return;
    }



    $.sValid.init({
        rules:{
            pdr_amount:"required",
        },
        messages:{
            pdr_amount:"请输入金额",
        },
        callback:function (eId,eMsg,eRules){
            if(eId.length >0){
                var errorHtml = "";
                $.map(eMsg,function (idx,item){
                    errorHtml += "<p>"+idx+"</p>";
                });
                errorTipsShow(errorHtml);
            }else{
                errorTipsHide();
            }
        }
    });

    $('#saveform').click(function(){
							  
        if (!$(this).parent().hasClass('ok')) {
            return false;
        }

        if($.sValid()){
            var pdr_amount = $.trim($("#pdr_amount").val());
            $.ajax({
                type:'post',
                url:ApiUrl+"/index.php?act=member_fund&op=pdrecharge_add",
                data:{key:key,pdr_amount:pdr_amount},
                dataType:'json',
                success:function(e){
                    if(e.code == 200){
					 toPay(e.datas.pay_sn, "member_buy", "pdrecharge_pay");
                        //location.href = WapSiteUrl+'/tmpl/member/rechargecardlog_list.html';
                    }else{
                      //  loadSeccode();
                        //errorTipsShow('<p>' + result.datas.error + '</p>');
                    }
                }
            });
        }
    });
});
